#include <vector>
#include <iostream>

using namespace std;

int removeElement(vector<int>& nums, int val)
{
	int saveIndex = 0;
	int detectIndex = 0;
	while (detectIndex < nums.size())
	{
		if (nums[detectIndex] != val)
		{
			nums[saveIndex] = nums[detectIndex];
			saveIndex++;
		}
		detectIndex++;
	}
	return saveIndex;
}

int main()
{
	vector<int> num = { 3,2,2,3 };
	int val = 3;
	int count = removeElement(num, val);
	for (size_t i = 0; i < count; i++)
	{
		cout << num[i] << ',';
	}
	return 0;
}
